#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
const int MAXN = 20005;  // 最大顶点数
const int MAXM = 100005; // 最大边数
const int INF = 0x3f3f3f3f;
int n, s, t, cnt;
int head[MAXN], dist[MAXN];
bool vis[MAXN];
// 边结构
struct Edge {
    int to, cost, next;
} edge[MAXM * 2];  // 存储公交边，*2是因为是无向图
// 轻轨边结构
struct Metro {
    int from, to, cost;
} metro[MAXM];

// 添加边
void addEdge(int from, int to, int cost) {
    edge[cnt].to = to;
    edge[cnt].cost = cost;
    edge[cnt].next = head[from];
    head[from] = cnt++;
}

// Dijkstra算法
void dijkstra(int start, int* dist) {
    memset(vis, 0, sizeof(bool) * (n + 1));
    for(int i = 0; i <= n; i++) {
        dist[i] = INF;
    }
    dist[start] = 0;
    
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push({0, start});
    
    while(!pq.empty()) {
        int u = pq.top().second;
        pq.pop();
        
        if(vis[u]) continue;
        vis[u] = true;
        
        // 遍历所有邻接点
        for(int i = head[u]; i != -1; i = edge[i].next) {
            int v = edge[i].to;
            int cost = edge[i].cost;
            
            if(!vis[v] && dist[v] > dist[u] + cost) {
                dist[v] = dist[u] + cost;
                pq.push({dist[v], v});
            }
        }
    }
}

void solve() {
    while(cin >> n >> s >> t) {
        // 初始化
        cnt = 0;
        memset(head, -1, sizeof(int) * (n + 1));
        
        // 读取公交线路
        int m;
        cin >> m;
        for(int i = 0; i < m; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            // 添加双向边
            addEdge(a, b, c);
            addEdge(b, a, c);
        }
        
        // 读取轻轨线路
        int k;
        cin >> k;
        for(int i = 0; i < k; i++) {
            cin >> metro[i].from >> metro[i].to >> metro[i].cost;
        }
        
        // 计算从起点和终点出发的最短路
        static int dist_from_start[MAXN], dist_to_end[MAXN];
        dijkstra(s, dist_from_start);
        dijkstra(t, dist_to_end);
        
        // 计算最优方案
        int min_time = dist_from_start[t];
        int best_metro_station = 0;
        
        // 尝试使用每条轻轨线路
        for(int i = 0; i < k; i++) {
            int x = metro[i].from;
            int y = metro[i].to;
            int z = metro[i].cost;
            
            // 正向乘坐轻轨
            if(dist_from_start[x] != INF && dist_to_end[y] != INF) {
                int time = dist_from_start[x] + z + dist_to_end[y];
                if(time < min_time) {
                    min_time = time;
                    best_metro_station = x;
                }
                else if(time == min_time && x < best_metro_station) {
                    best_metro_station = x;
                }
            }
            
            // 反向乘坐轻轨
            if(dist_from_start[y] != INF && dist_to_end[x] != INF) {
                int time = dist_from_start[y] + z + dist_to_end[x];
                if(time < min_time) {
                    min_time = time;
                    best_metro_station = y;
                }
                else if(time == min_time && y < best_metro_station) {
                    best_metro_station = y;
                }
            }
        }
        
        // 输出结果
        cout << min_time << endl;
        if(best_metro_station == 0) {
            cout << "no metro" << endl;
        } else {
            cout << best_metro_station << endl;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}